home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Singles Flirt Up Your Life! (German)
/
Singles Flirt Up Your Life.iso
/
data1.cab
/
Statemachine
/
toilet.lua
< prev
next >
Wrap
Text File
|
2004-01-29
|
4KB
|
114 lines
-- toilet state machine
beginStateMachine()
onMsg("buildMenu", function(msg)
if (repairMenu()) then return end
-- build the pie menu
clearPieMenu();
local button ;
button = addPieMenuButton("pm_sitToilet", "sitToilet");
button.addDescription(ACTIVITY, "sitToilet");
-- button.addIcon("guiIconHygiene");
if (this.getDirtiness() > 0.01) then
button = addPieMenuButton("pm_clean", "clean");
button.addDescription(ACTIVITY, "clean");
button.addDescription(ACTIVITY, "improveObjectTidiness");
button.addIcon("guiIconWohnung");
end;
-- button.addIcon("guiIconWohnung");
end )
-- sit on toilet
onMsg("sitToilet", function(msg)
-- get the game object server
local gameObjectServer = getGameObjectServer();
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
-- if this is broken: abort characters action
if abortIfBroken(character) then return end;
-- walk to the closest action point
local actionPoint = character.getClosestFreeActionPointToClickPoint(this, {"sit"});
if (actionPoint) then
-- get the walk state object
local wso = character.walkSO;
if (wso.walkToActionPoint(actionPoint)) then
wso.queueStateMachine("toiletChar.sitDown", this);
else
print("no path found");
instantAbort(character, EMOTICON_NOPATH, "emoThink")
end
else
print("no action point found");
instantAbort(character, EMOTICON_CANNOT, "emoThink")
end
end )
-- clean on toilet
onMsg("clean", function(msg)
-- get the game object server
local gameObjectServer = getGameObjectServer();
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
-- if this is broken: abort characters action
if abortIfBroken(character) then return end;
-- if character is too unhappy: abort characters action
if instantAbortIfUnhappy(character, "clean", this) then return end;
-- walk to the closest action point
local actionPoint = character.getClosestFreeActionPointToClickPoint(this, {"clean"});
if (actionPoint) then
-- get the walk state object
local wso = character.walkSO;
if (wso.walkToActionPoint(actionPoint)) then
wso.queueStateMachine("toiletChar.cleanStart", this);
else
print("no path found");
--queueNextClean(character);
instantAbort(character, EMOTICON_NOPATH, "emoThink")
-- character.setEmoticon(EMOTICON_NOPATH, EMOTICON_DELAY);
-- sendMsg("emoThink", character.walkSO);
end
else
print("no action point found");
--queueNextClean(character);
instantAbort(character, EMOTICON_CANNOT, "emoThink")
-- character.setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
-- sendMsg("emoThink", character.walkSO);
end
end )
-- repair
onMsg("repair", function(msg)
print("onMsg repair");
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
-- walk to the closest action point
local actionPoint = character.getFreeActionPoint(this, "repair");
-- get the walk state object
local wso = character.walkSO;
if (actionPoint) then
-- create state machine contexts
local wsoContext = StateMachineContext();
-- store the action point
wsoContext.storeData("actionPointName", actionPoint.getName());
if (wso.walkToActionPoint(actionPoint)) then
wso.queueStateMachine("repairChar.repairStart", this, wsoContext);
else
print("no path found");
instantAbort(character, EMOTICON_NOPATH, "emoThink")
end
else
print("no action point found");
instantAbort(character, EMOTICON_CANNOT, "emoThink")
end
end )
endStateMachine()